/*
 * @Author: your name
 * @Date: 2021-08-23 08:36:43
 * @LastEditTime: 2022-03-07 10:08:05
 * @LastEditors: tc
 * @Description: In User Settings Edit
 * @FilePath: \yyzxwebd:\hsx\水文局设备运行维护管理平台\web\src\router\index.js
 */

import {createRouter, createWebHashHistory } from "vue-router"
import Index from '../views/Index.vue'
import homeApi from '@/api/home'
const routes = [
    {
        path: '/',
        redirect: '/login'
    },
    // 大屏
    {
        path: '/dashboard',
        name: "dashboard",
        component: () => import (/* webpackChunkName: "dashboard" */ "../views/dashboard/index.vue"),  
    },
    // 大屏02
    {
        path: '/largeScreen',
        name: "largeScreen",
        component: () => import (/* webpackChunkName: "dashboard" */ "../views/largeScreen/index.vue"),  
    },
    // 后台
    {
        path: "/admin",
        name: "admin",
        redirect: '/home',
        meta: {
            title: '后台管理',
            role: []
        },
        component: Index,
        children: [
            {
                path: "/home",
                name: "home",
                meta: {
                    title: '实况查看',
                    role: []
                },
                component: () => import (/* webpackChunkName: "dashboard" */ "../views/home/index.vue"),
            },
            {
                path: "/damMonitoring",
                name: "damMonitoring",
                meta: {
                    title: '堤坝监控',
                    role: []
                },
                component: () => import (/* webpackChunkName: "dashboard" */ "../views/damMonitoring/index.vue"),
            },
            {
                path: "/operationMonitoring",
                name: "operationMonitoring",
                meta: {
                    title: '设备监控',
                    role: []
                },
                component: () => import (/* webpackChunkName: "dashboard" */ "../views/operationMonitoring/index.vue"),
            },
            {
                path: "/patrolInspectionRecord",
                name: "patrolInspectionRecord",
                meta: {
                    title: '巡检记录',
                    role: []
                },
                component: () => import (/* webpackChunkName: "dashboard" */ "../views/patrolInspectionRecord/index.vue"),
            },
            {
                path: "/maintenanceRecord",
                name: "maintenanceRecord",
                meta: {
                    title: '维修记录',
                    role: []
                },
                component: () => import (/* webpackChunkName: "dashboard" */ "../views/maintenanceRecord/index.vue"),
            },
            {
                path: "/faultInformation",
                name: "faultInformation",
                meta: {
                    title: '故障信息',
                    role: []
                },
                component: () => import (/* webpackChunkName: "dashboard" */ "../views/faultInformation/index.vue"),
            },
            {
                path: "/smsContent",
                name: "smsContent",
                meta: {
                    title: '短信内容',
                    role: []
                },
                component: () => import (/* webpackChunkName: "dashboard" */ "../views/smsContent/index.vue"),
            },
            {
                path: "/basicInformation",
                name: "basicInformation",
                meta: {
                    title: '基础信息',
                    role: []
                },
                component: () => import (/* webpackChunkName: "dashboard" */ "../views/basicInformation/layout.vue"),
                children: [
                    {
                        path: "/monitoringPoint",
                        name: "monitoringPoint",
                        meta: {
                            title: '水库信息',
                            role: []
                        },
                        component: () => import (/* webpackChunkName: "dashboard" */ "../views/basicInformation/monitoringPoint/index.vue"),
                    },
                    {
                        path: "/videoCamera",
                        name: "videoCamera",
                        meta: {
                            title: '摄像机信息',
                            role: []
                        },
                        component: () => import (/* webpackChunkName: "dashboard" */ "../views/basicInformation/videoCamera/index.vue"),
                    },
                    {
                        path: "/sensor",
                        name: "sensor",
                        meta: {
                            title: '传感器信息',
                            role: []
                        },
                        component: () => import (/* webpackChunkName: "dashboard" */ "../views/basicInformation/sensor/index.vue"),
                    },
                    {
                        path: "/parts",
                        name: "parts",
                        meta: {
                            title: '配件信息',
                            role: []
                        },
                        component: () => import (/* webpackChunkName: "dashboard" */ "../views/basicInformation/parts/index.vue"),
                    },
                    {
                        path: "/watchList",
                        name: "watchList",
                        meta: {
                            title: '值班信息表',
                            role: []
                        },
                        component: () => import (/* webpackChunkName: "dashboard" */ "../views/basicInformation/watchList/index.vue"),
                    },
                    {
                        path: "/dataDictionary",
                        name: "dataDictionary",
                        meta: {
                            title: '数据字典',
                            role: []
                        },
                        component: () => import (/* webpackChunkName: "dashboard" */ "../views/basicInformation/dataDictionary/index.vue"),
                    },

                ]
            },
            {
                path: "/systemManagel",
                name: "systemManagel",
                meta: {
                    title: '系统管理',
                    role: []
                },
                component: () => import (/* webpackChunkName: "dashboard" */ "../views/systemManagel/layout.vue"),
                children: [
                    {
                        path: "/userManage",
                        name: "userManage",
                        meta: {
                            title: '用户信息',
                            role: []
                        },
                        component: () => import (/* webpackChunkName: "dashboard" */ "../views/systemManagel/userManage/index.vue"),
                    },
                    {
                        path: "/roleManage",
                        name: "roleManage",
                        meta: {
                            title: '角色管理',
                            role: []
                        },
                        component: () => import (/* webpackChunkName: "dashboard" */ "../views/systemManagel/roleManage/index.vue"),
                    },
                    {
                        path: "/operationLog",
                        name: "operationLog",
                        meta: {
                            title: '操作日志',
                            role: []
                        },
                        component: () => import (/* webpackChunkName: "dashboard" */ "../views/systemManagel/operationLog/index.vue"),
                    },
                ]
            }
        ]
    },
    {
        path: "/login",
        name: "Login",
        meta: {
            title: '登录'
        },
        component: () => import (/* webpackChunkName: "login" */ "../views/Login.vue")
    },
    {
        path: '/:pathMatch(.*)*',
        name: '404',
        meta: {
            title: '找不到页面'
        },
        component: () => import (/* webpackChunkName: "404" */'../views/404.vue')
    }, {
        path: '/403',
        name: '403',
        meta: {
            title: '没有权限'
        },
        component: () => import (/* webpackChunkName: "403" */ '../views/403.vue')
    }
];

const router = createRouter({
    history: createWebHashHistory(process.env.BASE_URL), // history模式
    routes
})

// router.beforeEach((to, from, next) => {
//     const token = localStorage.getItem('token')
//     if(token) {
//         if(to.path === '/login') {
//             homeApi.remind().then((res)=>{
//                 next('/home')
//             }).catch(err => {
//                 localStorage.clear()
//                 next()
//             })
//         }else {
//             next()
//         }
//     }else {
//         if(to.path === '/login'|| to.path === '/dashboard') {
//             next()
//         }else {
//             next('/login')
//         }
//     }
    
// })

export default router